﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace ProjectEuler.Extensions
{
    internal static class EventHandlerListExtensions
    {
        public static void FireEvent(this EventHandlerList list, Object key, Object sender)
        {
            var handler = (list[key] as EventHandler);

            if (handler != null)
            {
                handler(sender, EventArgs.Empty);
            }
        }

        public static void FireEvent(this EventHandlerList list, Object key, Object sender, PropertyChangedEventArgs args)
        {
            var handler = (list[key] as PropertyChangedEventHandler);

            if (handler != null)
            {
                handler(sender, args);
            }
        }
    }
}
